﻿using System;
using System.Collections.Generic;
using System.Text;

namespace RedBlueBalls
{
    /// <summary>
    /// Calculate the delta of red balls
    /// </summary>
    class RedDelta
    {
        private static List<int> list;
        private static int BEST_KEY = 2;
        private static int index;
        private static int key;

        public static void analyze(RedBlueBallRecord[] records)
        {
            list = new List<int>();

            foreach (RedBlueBallRecord record in records)
            {
                int delta = record.GetMaxSameDelta();
                Util.Add(list, delta);
            }
            index = list.Count / 10;
            key = list[index];

            StringBuilder sb = new StringBuilder();
            sb.Append("Max Delta: ");
            for (int i = 0; i < index; i++)
            {
                sb.Append(list[i].ToString("D1")).Append(' ');
            }
            Tracer.AppendMessage(sb.ToString());
        }

        public static bool predict(RedBlueBallRecord candidate)
        {
            if (candidate.GetMaxSameDelta() != BEST_KEY)
                return false;

            return true;
        }
    }
}
